package com.yc.exam.web;


import com.yc.exam.bean.Exam;
import com.yc.exam.bean.Result;
import com.yc.exam.bean.User;
import com.yc.exam.biz.ExamBiz;
import com.yc.exam.mapper.ExamMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ly
 * @since 2024-08-14
 */
@RestController
@RequestMapping("/exam")
public class ExamController {

    @Autowired
    ExamBiz examBiz;
    @Autowired
    ExamMapper examMapper;

    @RequestMapping("commit")
    public Result commit(@RequestBody Exam exam,
        @SessionAttribute User myinfo){
        exam.setUid(myinfo.getId());
        examBiz.commit(exam);
        return new Result(1,"考卷提交成功!", exam);
    }

    @RequestMapping("get")
    public Exam get(int pid, @SessionAttribute User myinfo){
        return examMapper.findById(pid, myinfo.getId());
    }

}

